package com.dfbz.设计模式.factory2;

import org.junit.Test;

public class Demo01 {

    @Test
    public void test1() throws Exception{

        FruitFactory fruitFactory=new FruitFactory();


        Class<Apple> appleClass = (Class<Apple>) Class.forName("com.dfbz.factory2.Apple");
        Class<Pear> pearClass = (Class<Pear>) Class.forName("com.dfbz.factory2.Pear");

        Apple fruit = fruitFactory.createFruit(appleClass);
        Pear pear = fruitFactory.createFruit(pearClass);

        fruit.getColor();
        pear.getColor();
    }
}
